#include "Draw.h"
#include "Main.h"

All::Random draw_random;

void All::Draw::Line(float right, float left) {
	//draw_random.logfile.open("RenderLog.txt");
	if (first) {
		glClear(GL_COLOR_BUFFER_BIT);
		first = false;
	}
	glColor3f(1.0, 1.0, 1.0);
	//glRectf(0.4, 0.0, 0.6, 1.0);
	/*glBegin(GL_QUAD_STRIP);
		glColor3f(1.0, 1.0, 1.0);
		glVertex2f(0.40, 0.00);
		glColor3f(0.0, 1.0, 1.0);
		glVertex2f(0.50, 0.00);
		glColor3f(1.0, 1.0, 1.0);
		glVertex2f(0.40, 1.00);
		glColor3f(0.0, 1.0, 1.0);
		glVertex2f(0.50, 1.00);
	glEnd();*/

	glBegin(GL_QUADS);
		glColor3f(1.0, 1.0, 1.0);
		glVertex2f(0.45, 0.00);
		glColor3f(0.0, 1.0, 1.0);
		glVertex2f(0.50, 0.00);
		glColor3f(0.0, 1.0, 1.0);
		glVertex2f(0.50, 1.00);
		glColor3f(1.0, 1.0, 1.0);
		glVertex2f(0.45, 1.00);

		glColor3f(0.0, 1.0, 1.0);
		glVertex2f(0.50, 0.00);
		glColor3f(1.0, 1.0, 1.0);
		glVertex2f(0.55, 0.00);
		glColor3f(1.0, 1.0, 1.0);
		glVertex2f(0.55, 1.00);
		glColor3f(0.0, 1.0, 1.0);
		glVertex2f(0.50, 1.00);
	glEnd();
	glFlush();
	//glutSwapBuffers();

	//double TimeNow = clock();

	/*for (double i = 1; i < 1000; i++) {
		double TimeNow = clock();
		glClear(GL_COLOR_BUFFER_BIT);
		glColor3f(1.0, 1.0, 1.0);
		glBegin(GL_LINES);
			glVertex3f(0.00 + (i / 5000), 0.00 + (i / 5000), 0.0);
			glVertex3f(0.50 + (i / 5000), 0.50 + (i / 5000), 0.0);
		glEnd();
		glFlush();
		cout << "Draw: " << draw_random.Timer(TimeNow) << endl;

		draw_random.writeLog(draw_random.Timer(TimeNow));
	}*/
	//draw_random.writeLog(draw_random.Timer(TimeNow));
	//draw_random.logfile.close();
}

void All::Draw::Background(float r, float g, float b) {
	printf("r: %.2g", r, "\n");
	printf("g: %.2g", g, "\n");
	printf("b: %.2g", b, "\n");
	//glClearColor(r, g, b, 0);
	glClear(GL_COLOR_BUFFER_BIT);
	glColor3f(r, g, b);
	glRectf(0.0, 0.0, 1.0, 1.0);
	glFlush();
	printf("Draw!\n");

	Line(0.45, 0.55);
	//glutSwapBuffers();
}
